- /* sdfcosSR.cpp by K.Tsuru */
- // function ID 3104 DRADIX
- /*****************************
- SDouble class
- trigonometric function cos x
- using sereies and reduction method
- enum { COS_CALC = 1, SIN_CALC = 2, TAN_CALC = 3, COT_CALC = 4};
- ******************************/
- #ifndef SN_H
- #include "sn.h"
- #endif
- #define usesCosSeriesInCos 1
- SDouble CosS_RN(const SDouble& x){
- if(x.Sign(3104) == 0) return 1.0; // x = 0
- #if usesCosSeriesInCos
- // |x| is very small.
- if(x.NetRdxExp() < -4) return CosSeries(x); // |x| < 1.0e-16 ver.2.18
-
- uint fig = x.Last() - x.First() +1u;
- double c;
-
- if(fig <= 5u){ // x is a short number.
- double dblX = doubleD(x, 0), absX = fabs(dblX);
- // y is short and small, then call CosSeries()
- c = (absX > M_PI_4) ? 1.0 : log10((double)x.MaxSize()*absX) - 2.5;
- if(c < 0) return CosSeries(x);
- }
- #endif
- SDouble y, r;
- int func = COS_CALC;
- int sgn = GetTriCalcMethod(x, y, &func); // |y| < pi/4
-
- if(sgn == 0){ // y = -1, 0, 1
- x.upToTerm = 0;
- return y;
- }
- #if usesCosSeriesInCos
- // y is long but small.
- double dblY = doubleD(y, 0), absY = fabs(dblY);
- c = (double)x.MaxSize()/64 + log10(absY) + 0.5;
- if(c < 0){
- if(func == COS_CALC) r = CosSeries(y);
- else r = SinSeries(y);
- goto Ret;
- }
- #endif
- //RN : using x/R^n reduction method
- if(func == COS_CALC) r = CosRN(y);
- else r = SinRN(y);
- Ret:
- if(sgn < 0) r.ChangeSign(); // r = -r;
- return r;
- }
sdfcosSR.cpp : last modifiled at 2017/09/03 16:01:42(1,440 bytes)
created at 2017/10/07 10:22:50
The creation time of this html file is 2017/10/07 11:29:39 (Sat Oct 07 11:29:39 2017).